import Button from './Button';
import Input from './Input';

const MyUI = {};
const MyButton = {};
const MyInput = {};

const componentPool = [
  Button,
  Input
];

MyButton.install = Vue => Vue.component(Button.name, Button);
MyInput.install = Vue => Vue.component(Input.name, Input);

export {
  MyButton,
  MyInput
}

MyUI.install = function(Vue, options) {
  // Vue.component;
  // Vue.directive
  // Vue.mixin
  // Vue.prototype.$http = function() {}

  // console.log(options); // 组件库的配置对象， 实现按需加载

  if (options && options.components) {
    const components = options.components;

    components.map(compName => {
      componentPool.map(c => {
        if (compName === c.name) {
          Vue.component(c.name, c);
        }
      })
    })
  } else {
    componentPool.map(c => {
      Vue.component(c.name, c);
    })
  }

}

export default MyUI;